/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Aps_PlantCalendar",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using DGZImp.ApsProject.DomainModels;
using DGZImp.ApsProject.IServices;
using DGZImp.ApsProject.Dtos;
using DGZImp.Core.Utilities.Response;

namespace DGZImp.ApsProject.Controllers
{
    public partial class Aps_PlantCalendarController
    {
        private readonly IAps_PlantCalendarService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Aps_PlantCalendarController(
            IAps_PlantCalendarService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        /// <summary>
        /// 工厂行事历生成
        /// </summary>
        /// <param name="calendarInfo"></param>
        /// <returns></returns>
        [HttpPost("GenerateCalendarData")]
        public async Task<ApiResponse<string>> GenerateCalendarData([FromBody] ReqApsCalendarInfo calendarInfo)
        {
            var result = await _service.GenerateCalendarData(calendarInfo);
            return ApiRes.Success(result);
        }

        /// <summary>
        /// 工厂行事历更新
        /// </summary>
        /// <param name="calendarInfo"></param>
        /// <returns></returns>
        [HttpPost("GenerateCalendarDataUpdate")]
        public async Task<ApiResponse<string>> GenerateCalendarDataUpdate([FromBody] ReqApsCalendarInfo calendarInfo)
        {
            var result = await _service.GenerateCalendarDataUpdate(calendarInfo);
            return ApiRes.Success(result);
        }


        /// <summary>
        /// 工厂行事历获取
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        [HttpGet("GetList")]
        public async Task<ApiResponse<List<ResLeanApsLineCalendarInfo>>> GetList(string time)
        {
            var res = await _service.GetList(time);
            return ApiRes.Success(res);
        }

        /// <summary>
        /// 工厂调整班次
        /// </summary>
        /// <param name="ShiftId"></param>
        /// <param name="PlantCalendarId"></param>
        /// <returns></returns>
        [HttpGet("UpdateShift")]
        public async Task<ApiResponse<object>> UpdateShift(long? ShiftId, long? PlantCalendarId)
        {
            var msg = await _service.UpdateShift(ShiftId, PlantCalendarId);
            return ApiRes.SuccessMsg(msg);
        }
    }
}
